﻿using Castle.MicroKernel.Registration;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WJP.Dependency;

namespace WJP.Utils.Excels
{
    public static class ExcelManager
    {
        /// <summary>
        /// 注册默认的<see cref="IExcelPort"/>实现类型
        /// </summary>
        /// <param name="excelPortType"></param>
        public static void RegisterDefaultExcelPort(Type excelPortType)
        {
            IocManager.Instance.IocContainer
                .Register(Component.For<IExcelPort>().ImplementedBy(excelPortType).IsDefault());
        }

        /// <summary>
        /// 获取Excel操作对象
        /// </summary>
        /// <returns></returns>
        public static IExcelPort GetExcelPort()
        {
            if (!IocManager.Instance.IsRegistered<IExcelPort>())
                throw new NotSupportedException("没有实现了IExcelPort接口的插件");

            return IocManager.Instance.Resolve<IExcelPort>();
        }
    }
}
